from sqlalchemy import Column, DateTime, Integer, String, func
from sqlalchemy.orm import relationship

from app.bot.services.date_time import get_date_time
from app.database.models.base import Base


class ProxyProvider(Base):
    __tablename__ = "provider"

    id = Column(Integer, primary_key=True)
    name = Column(String(50), nullable=False)
    name_eng = Column(String(50), nullable=False)
    servers = relationship("Server", back_populates="provider")
    orders = relationship("Order", back_populates="provider")
    created_at = Column(DateTime, server_default=func.now())

    def __str__(self):
        return self.name

    def __repr__(self):
        return f"<Provider №{self.id} {self.name}>"
